What is @tiptap/extension-blockquote?
@tiptap/extension-blockquote is an extension for the Tiptap editor that allows users to easily add and manage blockquotes within their rich text content. It provides a simple way to include blockquote formatting, making it easier to highlight quotes or important text in a visually distinct manner.
Adding a Blockquote
This code demonstrates how to add the Blockquote extension to a Tiptap editor instance and toggle a blockquote in the editor content.
import { Blockquote } from '@tiptap/extension-blockquote';
import { Editor } from '@tiptap/core';
const editor = new Editor({
extensions: [
Blockquote,
],
content: '<p>Hello World!</p>',
});
editor.chain().focus().toggleBlockquote().run();
Customizing Blockquote Styling
This code shows how to extend the Blockquote extension to add custom styling attributes and apply custom CSS to the blockquote element.
import { Blockquote } from '@tiptap/extension-blockquote';
import { Editor } from '@tiptap/core';
import { css } from 'styled-components';
const CustomBlockquote = Blockquote.extend({
addAttributes() {
return {
class: {
default: 'custom-blockquote',
},
};
},
});
const editor = new Editor({
extensions: [
CustomBlockquote,
],
content: '<p>Hello World!</p>',
});
const styles = css`
.custom-blockquote {
border-left: 4px solid #ccc;
padding-left: 16px;
color: #666;
}
`;
editor.chain().focus().toggleBlockquote().run();